package com.service.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.service.dao.dto.MemberRank;
import com.service.dao.dto.rep.OrderProductHrComboRep;
import com.service.dao.model.OrderProductHrCombo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 算力订单
 *
 * @author xxxx
 * @email xxxx@qq.com
 * @date 2019-11-10 22:06:11
 */
@Mapper
public interface OrderProductHrComboMapper extends BaseMapper<OrderProductHrCombo> {

    BigDecimal getTotalOrderNumByOrderStatus(@Param("orderStatus") List<Integer> orderStatus, @Param("memberId") Integer memberId);

    List<OrderProductHrCombo> listOrderByMemberStatus(@Param("coinsId") Integer coinsId, @Param("orderStatus") List<Integer> orderStatus, @Param("memberStatus") Integer memberStatus, @Param("startTime") Date startTime);

    /**
     * 统计会员某个算力商品购买数量
     *
     * @param memberId
     * @param orderStatus
     * @param comboId
     * @return
     */
    Integer totalEffectiveOrderByMemberIdAndComboId(@Param("memberId") Integer memberId, @Param("orderStatus") List<Integer> orderStatus, @Param("comboId") Integer comboId);

    /**
     * 统计当前用户的有效算力订单
     *
     * @param memberId 购买者用户id
     * @param coinsId  币种id集合
     * @return
     */
    BigDecimal totalEffectiveOrderByMemberId(@Param("memberId") Integer memberId, @Param("coinsId") Integer coinsId, @Param("orderStatus") Integer orderStatus);

    BigDecimal totalEffectiveHrRateByMemberId(@Param("memberId") Integer memberId, @Param("orderStatus") List<Integer> orderStatus, @Param("orderSource") List<Integer> orderSource, @Param("coinsName") String coinsName);

    BigDecimal totalEffectiveOrderByMemberIds(@Param("memberIds") List<Integer> memberIds, @Param("coinsId") Integer coinsId, @Param("orderStatus") Integer orderStatus, @Param("coinsName") String coinsName);

    /**
     * 查询会员是否有下单金额大于0的付款状态订单
     *
     * @param memberId
     * @param orderStatus
     * @return
     */
    BigDecimal totalEffectiveHrRateLargeThanZeroByMemberId(@Param("memberId") Integer memberId, @Param("orderStatus") List<Integer> orderStatus);


    List<OrderProductHrCombo> listEffectiveOrderByMemberIds(@Param("memberIds") List<Integer> memberIds, @Param("coinsId") Integer coinsId, @Param("orderStatus") Integer orderStatus);

    BigDecimal totalEffectiveOrderMoneyByMemberIdsAndStatusAndSourceList(@Param("memberIds") List<Integer> memberIds, @Param("orderStatus") List<Integer> orderStatus, @Param("orderSource") List<Integer> orderSource);

    /**
     * @param memberIds
     * @param orderStatus
     * @param orderSource
     * @return
     */
    BigDecimal totalEffectiveOrderMoneyByMemberIdsAndStatusAndSourceListAndTime(@Param("memberIds") List<Integer> memberIds, @Param("orderStatus") List<Integer> orderStatus, @Param("orderSource") List<Integer> orderSource,
                                                                                @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    /**
     * 统计用户某个商品未支付订单
     *
     * @param memberId
     * @param comboId
     * @return
     */
    Integer totalNotPayOrderByMemberIdAndComboId(@Param("memberId") Integer memberId, @Param("comboId") Integer comboId);

    /**
     * 查询x时间前未支付订单列表
     *
     * @param orderStatus
     * @param beforeDate
     * @return
     */
    List<OrderProductHrCombo> listNotPayByTime(@Param("orderStatus") Integer orderStatus, @Param("beforeDate") Date beforeDate);

    /**
     * 统计用户某天的某种币购买了多少算力
     *
     * @param memberId
     * @param fromCoinsName
     * @param someDay
     * @return
     */
    BigDecimal totalTodayBuyByMemberIdAndCoinsIdAndSomeDay(@Param("memberId") Integer memberId, @Param("fromCoinsName") String fromCoinsName, @Param("someDay") String someDay);

    List<OrderProductHrCombo> pageByCoins(@Param("orderStatus") Integer orderStatus, @Param("memberId") Integer memberId, @Param("coinsId") Integer coinsId);

    List<OrderProductHrComboRep> pageByCoins1(@Param("orderStatus") Integer orderStatus, @Param("memberId") Integer memberId, @Param("coinsId") Integer coinsId, @Param("type") Integer type);

    List<OrderProductHrCombo> listEffectiveOrderByMemberId(@Param("memberId") Integer memberId, @Param("orderStatus") List<Integer> orderStatus, @Param("orderSource") List<Integer> orderSource);


    /**
     * @Description: 统计用户们消费
     * @Author: ty
     * @Date: 2021/4/30 15:25
     * @param: [memberIds]
     * @return: java.math.BigDecimal
     **/
    BigDecimal totalEffectiveOrderPayByMemberList(@Param("memberIds") List<Integer> memberIds, @Param("orderStatus") List<Integer> orderStatus);

    /**
     * @Description: 统计本月排行
     * @Author: ty
     * @Date: 2021/5/6 15:19
     * @param: [coinsName, currentMonth, limitNum]
     * @return: java.util.List<com.service.dao.dto.MemberRankRep>
     **/
    List<MemberRank> totalRankByPayMoneyAndSomeMonth(@Param("coinsName") String coinsName, @Param("currentMonth") String currentMonth, @Param("limitNum") Integer limitNum);

    /**
     * @Description: 统计全网有效算力
     * @Author: ty
     * @Date: 2021/5/8 14:28
     * @param: [orderStatus]
     * @return: java.math.BigDecimal
     **/
    BigDecimal totalAllEffectiveOrderPay(@Param("orderStatus") List<Integer> orderStatus);

    /**
     * @Description: 统计用户列表的有效算力T数
     * @Author: ty
     * @Date: 2021/5/8 16:02
     * @param: [memberIds, orderStatus]
     * @return: java.math.BigDecimal
     **/
    BigDecimal totalEffectiveHashRateByMemberIdsAndStatus(@Param("memberIds") List<Integer> memberIds, @Param("orderStatus") List<Integer> orderStatus, @Param("currentMonth") String currentMonth);


    BigDecimal totalStatementByParam(@Param("someDay") String someDay, @Param("orderStatus") List<Integer> orderStatus);

    /**
     * @Description: 获取当前用户最早购买的有效订单
     * @Author: ty
     * @Date: 2021/6/9 14:03
     * @param: [memberId, coinsName]
     * @return: com.service.dao.model.OrderProductHrCombo
     **/
    OrderProductHrCombo getFirstEffectOrderByMemberIdAndCoinsName(@Param("memberId") Integer memberId, @Param("coinsName") String coinsName, @Param("orderStatus") List<Integer> orderStatus);

    /**
     *  根据状态统计用户伞下算力
     * @param memberIds
     * @param orderStatus
     * @return
     */
    BigDecimal totalUmbrellaEffectiveHashRateByMemberIdsAndStatus(@Param("memberIds") List<Integer> memberIds, @Param("orderStatus") List<Integer> orderStatus);
}
